import Vue from "vue"
const requireComponent = require.context(
    // 其组件目录的相对路径
    './',
    // 是否查询其子目录
    false,
    // 匹配基础组件文件名的正则表达式
    /.js$/
)
console.log(requireComponent)
const camelCase = (str) => {
    return str.charAt(0).toUpperCase() + str.slice(1)
}
requireComponent.keys().forEach(fileName => {
    console.log(fileName, 'fileName')
    if (fileName !== './index.js') {
        const componentConfig = requireComponent(fileName)
        const componentName = camelCase(fileName
            .split('/')
            .pop()
            .replace(/\.\w+$/, ''))
            Vue.prototype[componentName] = componentConfig.default || componentConfig
    }
})